package com.service.test;

import java.io.IOException;
import java.lang.reflect.Proxy;
import java.util.*;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.ConfigurationFactory;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.http.entity.ContentType;
import org.aopalliance.intercept.Interceptor;
import org.apache.commons.collections.*;
import org.apache.commons.collections.map.*;
import org.apache.commons.collections.map.LRUMap;
import org.apache.commons.io.FileSystemUtils;
import org.apache.commons.lang.WordUtils;
import org.apache.commons.validator.*;

public class Main {

	/**
	 * @param args
	 * @throws ConfigurationException 
	 */
	public static void main(String[] args) throws Exception {
		
		OrderedMap om = new LinkedMap();
		om.put("FIRST", "firstValue");
		om.put("SECOND", "secondValue");
		om.put("THIRD", "thirdValue");
		
		System.out.println(om.firstKey());
		System.out.println(om.lastKey());
		System.out.println(om.nextKey("SECOND"));
		System.out.println(om.previousKey("THIRD"));
		
		
		LRUMap map = new LRUMap();
		
		long freeSpace = FileSystemUtils.freeSpace("C:/");
		System.out.println(freeSpace / (1000 * 1000 * 1000));
		
		System.out.println(WordUtils.swapCase("abCd"));
		System.out.println(WordUtils.uncapitalize("SDac"));
		
		boolean result = EmailValidator.getInstance().isValid("ABC");
		System.out.println(result);
		
		//String configurationFileName = "";
		//ConfigurationFactory configurationFactory = new ConfigurationFactory();
		//configurationFactory.setConfigurationFileName(configurationFileName);
		//String fileName = "config.xml";
		//DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(fileName);
		//DefaultConfigurationBuilder.ConfigurationProvider provider = new DefaultConfigurationBuilder.ConfigurationProvider();
		 
		//builder.addConfigurationProvider("child", provider);
		//Configuration config = builder.getConfiguration();
		//System.out.println(config.getProperty("child"));

		/*
		Configuration config = new PropertiesConfiguration("com/service/test/config.properties");
		System.out.println(config.getProperty("name"));
		System.out.println(config.getString("email"));
		
		Configuration xmlConfig = new XMLConfiguration("config.xml");
		System.out.println(Arrays.toString(xmlConfig.getStringArray("child.name[@attr]")));
		System.out.println(Arrays.toString(xmlConfig.getStringArray("child.name")));
		 
		System.out.println(xmlConfig.getString("child2.email"));
		*/
		
		/*
		String url = "http://localhost:8081/examples/bb.jsp";
		HttpPost hp = new HttpPost(url);
		List <NameValuePair> nvps = new ArrayList <NameValuePair>();
		nvps.add(new BasicNameValuePair("name","kitty"));
		nvps.add(new BasicNameValuePair("password","pwd"));
		UrlEncodedFormEntity uefe = new UrlEncodedFormEntity(nvps);
		hp.setEntity(uefe);
		HttpClient hc = new DefaultHttpClient();
		
		try {
			HttpResponse hr = hc.execute(hp);
			if (hr.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
				System.out.println(EntityUtils.toString(hr.getEntity()));
			}
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/
		
		/*
		Interface target = new DefaultInterface();
		Interface proxy = (Interface)Proxy.newProxyInstance(Interface.class.getClassLoader(), new Class<?>[]{Interface.class}, new DynamicProxy(target));
		proxy.play();
		*/
	}
	

}
